<div class="js-response grid_17 alpha omega js-responses">
<?php if(empty($this->request->params['named']['cat'])): ?>


	<?php echo $this->Form->create('Project', array('class' => 'ideasadd-form clearfix alpha omeaga js-ajax-form', 'id' => 'ProjectSearchForm', 'action' => 'index')); ?>
	<div class="js-overlabel text-wrapper grid_12">
		<?php echo $this->Form->input('q', array('class' => '', 'label' => __l('Enter your idea'), 'id' => 'project_ideas')); ?>
		<?php echo $this->Form->input('type', array('value' => 'idea','type'=>'hidden')); ?>


	</div>
	<?php echo $this->Form->submit(__l('POST')); ?>
	<?php echo $this->Form->end(); ?>


	<?php if(!empty($this->request->data['Project']['q'])): ?>
		<div class="vote-info clearfix">
			<?php if(!empty($projects)): ?>
			  <?php if(count($projects) > 1): ?>
				<p class="grid_left"><?php echo __l(' Vote for one of these? Or '); ?></p>
			  <?php else: ?>
    			<p class="grid_left"><?php echo __l(' Vote for this? Or '); ?></p>
			  <?php endif; ?>
			<?php endif; ?>
			<div class="cancel-block">
				<?php echo $this->Html->link(__l('Create new idea'), array('controller'=>'projects','action'=>'add','name'=>$this->request->data['Project']['q']), array('title' => __l('Create new idea')));  ?>
			</div>
			
		</div>
	<?php endif; ?>
	
<h2 class="idea-title"><?php echo __l('Vote ideas for funding'); ?></h2>
<div class="content-info"><?php echo __l('Top voted ideas will be choosen for funding by admin'); ?></div>
<?php endif; ?>
			<?php $ol_class = "list project-list";
			$li_class = "";
	?>
		<ol class="idea-list clearfix <?php echo $ol_class; ?>">
			<?php
				if (!empty($projects)):
					$i = 0;
					foreach ($projects as $project):
						$class = null;
						if ($i++ % 2 == 0) {
							$class = 'alpha';							
						}
						else{

							$class = 'altrow alpha';
						}
	  ?>
				<li class="clearfix <?php echo $li_class; ?> <?php echo $class; ?>">
					<div class="">
						<div class="l-curve-top l-curve-top-in">
							<div class="r-curve-top r-curve-top-in">
								<div class="top-bg top-bg-in"></div>
							</div>
						</div>
						<div class="shad-bg-lft shad-bg-lft-in">
							<div class="shad-bg-rgt shad-bg-rgt-in">
								<div class="shad-bg">
											<div class="center center1 clearfix">
												<div class="clearfix">
												<div class="clearfix">
													<div class="grid_5 omega">
													<?php echo $this->Html->link($this->Html->showImage('Project', $project['Attachment'], array('dimension' => 'medium_big_thumb', 'alt' => sprintf(__l('[Image: %s]'), $this->Html->cText($project['Project']['name'], false)), 'title' => $this->Html->cText($project['Project']['name'], false)),array('aspect_ratio'=>1)), array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false)); ?>
												</div>
													<div class="grid_11 grid_right omega">
													<div class="project-head clearfix">
													<h3><?php echo $this->Html->link($this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words']),array('controller' => 'projects', 'action' => 'view',  $project['Project']['slug'], 'admin' => false), array('escape' => false, 'title' => $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['name'], false), 53), $project['Project']['detected_suspicious_words'])));?></h3>
													</div>
													<p class="author-username1"> <?php echo __l('by') . ' '; ?><?php echo $this->Html->link($this->Html->cText($project['User']['username']), array('controller' => 'users', 'action' => 'view', $project['User']['username']), array('escape' => false, 'title' => $this->Html->cText($project['User']['username'], false)));?></p>
													<p class=""><?php echo $this->Html->filterSuspiciousWords($this->Html->truncate($this->Html->cText($project['Project']['short_description'], false), 200), $project['Project']['detected_suspicious_words']);?></p>
														


                                                    <div class="clearfix">

				                                        <div class="clearfix grid_6 alpha omega ">
             													<?php
        															$location = array();
        															$place = '';
        															if (!empty($project['City'])) :
        																if (isset($project['City']['name']) && !empty($project['City']['name'])) {
        																	$location[] = $project['City']['name'];
        																}
        															endif;
        															if (!empty($project['Country']['name'])) :
        																$location[] = $project['Country']['name'];
        															endif;
        															$place = implode(', ', $location);
        															if ($place):
        																if(!empty($project['Country']['iso2'])):
        														?>
     														<p class="place-name1">
        															<span class="flags flag-<?php echo strtolower($project['Country']['iso2']); ?>" title ="<?php echo $project['Country']['name']; ?>"><?php echo $project['Country']['name']; ?></span>
        														<?php endif;
        																echo $this->Html->link($place, array('controller' => 'projects', 'action' => 'index', 'city'=>$project['City']['slug']), array('escape' => false));
        															endif; ?>
													        </p>
				                                <dl class="feature-list">
													<?php if(!Configure::read('Project.is_fb_project_comment_enabled')): ?>
														<dt class="comments" title="<?php echo __l('Comments'); ?>"><?php echo __l('Comments:') . ' '; ?></dt>
															<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_comment_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Comments'), array('escape' => false)); ?></dd>
														<?php endif; ?>
														<dt class="updates" title="<?php echo __l('Updates'); ?>"><?php echo __l('Updates:') . ' '; ?></dt>
															<dd><?php
															if(!empty($project['Project']['feed_url']) && Configure::read('Project.is_enable_rss_feed')){
																	echo $this->Html->link($this->Html->cInt($project['Project']['project_feed_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Updates'), array('escape' => false));
															} else{
																echo $this->Html->link($this->Html->cInt($project['Project']['blog_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug'], '#_Updates'), array('escape' => false));
															}


														?></dd>
														<dt class="views" title="<?php echo __l('Views'); ?>"><?php echo __l('Views:') . ' '; ?></dt>
															<dd><?php echo $this->Html->link($this->Html->cInt($project['Project']['project_view_count']), array('controller' => 'projects', 'action' => 'view', $project['Project']['slug']), array('escape' => false)); ?></dd>
													</dl>
										

													</div>



							<div class="grid_5 clearfix time-detail-block">
									               <div class="clearfix"><dl class="deal-discount clearfix">
															<dt><?php echo __l('Needed amount') ?></dt>
															<dd><?php echo Configure::read('site.currency') . $this->Html->cCurrency($project['Project']['needed_amount']); ?></dd>
														</dl>
														</div>
									
                                                <div class="clearfix">
											     		<ul class="votebg">
														<li>
														<span class="js-idea-vote-count-<?php echo $project['Project']['id']; ?> vote-count-value"><?php echo $this->Html->cInt($project['Project']['total_ratings']); ?></span> <?php echo __l('Votes'); ?>
														</li>
														</ul>									
		
													<?php
													$rated_class = '';
													if($this->Auth->sessionValid() && !empty($project['ProjectRating']) && $project['ProjectRating'][0]['user_id'] == $this->Auth->user('id')):
														$rated_class = 'voted';
													endif;
													if($this->Auth->sessionValid() && $project['Project']['user_id'] == $this->Auth->user('id')):
														$rated_class = 'voted';
													endif;
													?>
													<p class="follow pledge grid_left <?php echo $rated_class; ?>">
														<?php
															if($this->Auth->sessionValid()):
														?>
															<a class="vote-link js-idea-rating { 'container': 'js-idea-vote-display-<?php echo $project['Project']['id'];?>'}">
																<?php echo __l('Vote'); ?>
															</a>
														<?php
															else:
																echo $this->Html->link(__l('Vote'), array('controller' => 'users', 'action' => 'login'), array('escape' => false, 'title' => __l('Vote')));
															endif;
														?>

													</p>
													<?php if($this->Auth->sessionValid() && $project['Project']['user_id'] != $this->Auth->user('id') && empty($project['ProjectRating'])): ?>
														<div class="vote-ratings grid_left vote-container" id="vote-ratings-container-<?php echo $project['Project']['id'];?>">
														<?php if (Configure::read('Project.is_enable_idea')): ?>
															<div class="js-idea-vote-display-<?php echo $project['Project']['id']; ?> starnew-rating js-idea-rating-display js-rating-display {'count':'js-idea-vote-count-<?php echo $project['Project']['id']; ?>'}">
																<?php
																	$average_rating = 0;
																	echo $this->element('_star-rating', array('project_id' => $project['Project']['id'], 'current_rating' => $average_rating ,'total_rating' => $project['Project']['total_ratings'],'rating_count' => $project['Project']['project_rating_count'], 'canRate' => ($this->Auth->sessionValid() && $project['Project']['user_id'] != $this->Auth->user('id')) ? 1 : 1));
																?>
															</div>
														<?php endif; ?>
													</div>
													<?php endif; ?>
													</div>
													</div>

                                                    </div>



                                                        </div>
									
												
						
												</div>
											</div>
											</div>
   								</div>
							</div>
						</div>
						<div class="l-curve-bot l-curve-bot-in">
							<div class="r-curve-bot r-curve-bot-in">
								<div class="bot-bg bot-bg-in"></div>
							</div>
						</div>
					</div>
				</li>
			<?php
					endforeach;
				else:
			?>
				<li class="main-section">
                  <div class="notice-block">
				<p class="notice">
					<?php 
							 echo __l('No ideas available');
						?>
					</p>
					</div>
				</li>
			<?php
				endif;
			?>
		</ol>

		<div class="clearfix">
			<?php if (!empty($projects)) { ?>
				<div class="paging project-paging js-pagination"><?php echo $this->element('paging_links'); ?></div>
			<?php } ?>
		</div>

</div>
<?php 		if(empty($this->request->params['isAjax'])): ?>
<div class="grid_7 idea-side2 omega">
					<?php echo $this->element('funding-projects', array('config' => 'sec'));?>
					<div class="add-project-link">
						<a href="<?php echo Router::url(array('controller' => 'projects', 'action' => 'add', 'admin' => false),true); ?>">
							<span><?php echo __l('Post ');?></span>
							<?php echo __l('your ideas');?>
						<span class="small-text"><?php echo __l('Add your ideas here');?></span>
						</a>
					</div>
</div>
<?php endif; ?>
